package com.hsh.controller;

import com.hsh.async.AsyncThreadPool;
import com.hsh.persist.BaseController;
import com.hsh.utils.vo.Response;
import com.hsh.vo.dto.convert.MapStructConvertVo;
import com.hsh.vo.dto.convert.Users;
import com.hsh.vo.dto.convert.UsersVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

@Api(value = "MapStructConvert", tags = "MapStructConvert")
@RestController
@RequestMapping("/test/map/struct")
public class MapStructController extends BaseController {

    //    @Autowired
//    MapStructConvertVo mapStructConvert;
//
//    @Test
//    public void dbDispose() {
//        Users users = new Users(1001, "阿海", new BigDecimal("13.550"), 1);
//        UsersVo toUsersVo = mapStructConvert.usersConvertToUsersVo(users);
//        System.out.println(JSON.toJSONString(toUsersVo, true));
//    }

    @ApiOperation("mapConvertDto")
    @GetMapping("/test")
    public Response dbDispose() {
        Users users = new Users(1001, "阿海", new BigDecimal("13.550"), 1);
        UsersVo toUsersVo = MapStructConvertVo.INSTANCE.usersConvertToUsersVo(users);
        AsyncThreadPool.scheduledThreadPool.schedule(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(i);
            }
        }, 10, TimeUnit.SECONDS);


        AsyncThreadPool.cachedThreadPool.execute(() -> {
            for (int i = 10; i < 20; i++) {
                System.out.println(i);
            }
        });
        return Response.success(toUsersVo);
    }

}
